package com.raising.modules.sys.service;

import com.raising.framework.service.CrudService;
import com.raising.modules.sys.dao.SysTipDao;
import com.raising.modules.sys.entity.SysTipVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * 资源服务
 * 
 * @author gaoy
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class SysTipService extends CrudService<SysTipDao, SysTipVo> {

	/**
	 * 获取菜单
	 * @param permissions
	 * @return
	 */
	public List<SysTipVo> findMenus(Set<String> permissions) {
		List<SysTipVo> allResources = getList(null);
		List<SysTipVo> menus = new ArrayList<SysTipVo>();
		for (SysTipVo resource : allResources) {
			if (resource.isRootNode()) {
				continue;
			}
			menus.add(resource);
		}
		return menus;
	}

	/**
	 * 查询是否存在子节点
	 * @param sysTipVo
	 * @return
	 */
	public int findNext(SysTipVo sysTipVo){
		return dao.findNext(sysTipVo);
	}

}
